package applet.source;

//
//  Utils.java
//  TestAppletXcode
//
//  Created by Thibaud PIQUET on 11/03/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

import java.io.File;
import javax.swing.ImageIcon;

/**
 *
 * @author Thibaud PIQUET
 * Version 1.1, Krishen SOOBRAYEN : 05/04/2011 : Inclure le format Graphml
 */
public class Utils {
    public final static String tcl = "tcl";
    public final static String rig = "rig";
    public final static String xml = "xml";
    public final static String net = "net";
    public final static String brite = "brite";
    public final static String gml = "gml";
    public final static String graphe = "graphe";
    public final static String TCL = "TCL";
    public final static String RIG = "RIG";
    public final static String XML = "XML";
    public final static String NET = "NET";
    public final static String BRITE = "BRITE";
    public final static String GML = "GML";
    public final static String GRAPHE = "GRAPHE";
    public final static String graphml = "graphml";
    public final static String GRAPHML = "GRAPHML";
    /*
     * Get the extension of a file.
     */
    public static String getExtension(File f) {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');
		
        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }
	
    /** Returns an ImageIcon, or null if the path was invalid. */
    protected static ImageIcon createImageIcon(String path) {
        java.net.URL imgURL = Utils.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }
}
